from page.base_page import BasePage
from appium.webdriver.common.appiumby import AppiumBy as By
class OwnPage(BasePage):
    """个人编辑页面"""
    #定位器
    edit_locator=(By.XPATH,'//android.widget.ImageView[@content-desc="编辑"]')
    edit_profile_locator = (By.XPATH, '//android.widget.TextView[@resource-id="com.xiachufang:id/edit_user_config"]')
    personal_profile_locator = (By.ID, "com.xiachufang:id/profile_setting_desc")
    username_locator = (By.ID, "com.xiachufang:id/profile_setting_name")
    btn_locator = (By.ID, "com.xiachufang:id/profile_setting_headIcon")
    checkmark_locator=(By.ID,"com.xiachufang:id/menu_crop")
    save_locator=(By.ID,"com.xiachufang:id/navigation_right_btn")
    currently_username_locator=(By.ID, 'com.xiachufang:id/navigation_item_center_view_layout')
    save_currently_username_locator=(By.XPATH,'//android.widget.TextView[@resource-id="com.xiachufang:id/navigation_bar_title_layout"]')
    one_follow_locator = (By.XPATH,'(//android.widget.TextView[@resource-id="com.xiachufang:id/recipe_detail_follow_btn"])[1]')
    one_follow_text_locator=(By.XPATH,'//android.widget.TextView[@resource-id="com.xiachufang:id/recipe_detail_follow_btn" and @text="关注"]')
    def edit(self):
        """点击信息"""
        bp = BasePage(self.driver)
        bp.show_waiting(self.driver, self.edit_locator).click()
    def edit_profile(self):
        """点击编辑个人资料"""
        bp = BasePage(self.driver)
        bp.show_waiting(self.driver, self.edit_profile_locator).click()
    def username(self,content):
        """编辑用户名"""
        bp = BasePage(self.driver)
        bp.show_waiting(self.driver, self.username_locator).clear()
        bp.show_waiting(self.driver, self.username_locator).send_keys(content)
    def personal_profile(self,content):
        """编辑个人资料"""
        bp = BasePage(self.driver)
        bp.show_waiting(self.driver, self.personal_profile_locator).send_keys(content)
    def click_profile_picture(self):
        """点击上传头像"""
        bp = BasePage(self.driver)
        bp.show_waiting(self.driver, self.btn_locator).click()
    def image(self,):
        """点击打勾"""
        bp = BasePage(self.driver)
        bp.show_waiting(self.driver, self.checkmark_locator).click()
    def save(self):
        """点击保存"""
        bp = BasePage(self.driver)
        bp.show_waiting(self.driver, self.save_locator).click()
    def currently_username(self):
        """编辑个人资料页面表头文本"""
        return self.find_element(self.currently_username_locator).text
    def save_save_currently_username(self):
        """编辑个人资料页面表头文本"""
        return self.find_element(self.save_currently_username_locator).text
    def one_follow(self,):
        """点击已关注"""
        bp = BasePage(self.driver)
        bp.show_waiting(self.driver, self.one_follow_locator).click()
    def one_follow_text(self):
        """编辑个人资料页面表头文本"""
        return self.find_element(self.one_follow_locator).text

